﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PhuongTrinhBacHai
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnGiaiPhuongTrinh_Click(object sender, EventArgs e)
        {
            double a = double.Parse(txtA.Text);
            double b = double.Parse(txtB.Text);
            double c = double.Parse(txtC.Text);

            double delta = b * b - 4 * a * c;
            if (delta < 0) {
                lblKetQUa.Text = "Phuong Trinh Vo Nghiem";
            }
            else if (delta == 0)
            {
                double result = -Math.Sqrt(delta) / (2 * a);
                lblKetQUa.Text = "Phuong Trinh Nghiem Kep : " + result;
            }
            else {
                double result1 = -b + Math.Sqrt(delta) / (2 * a);
                double result2 = -b - Math.Sqrt(delta) / (2 * a);
                lblKetQUa.Text = "Phuong Trinh 2 Nghiem : " + result1 + " ," + result2;
            }
        }
    }
}
